
clear
set more off

log using ipvrct_replication_20170408.log, replace

use ipvrct_replication_20170408.dta, replace

* summary statistics & covariate balance

sort visitdate 
list visitdate in 1/5
gsort -visitdate
list visitdate in 1/5

tab ipv_version, missing

tab female ipv_version, col chi2
tabstat age, stat(n mean sd) by(ipv_version)
ttest age if ipv_version==1 | ipv_version==2, by(ipv_version)
ttest age if ipv_version==1 | ipv_version==3, by(ipv_version)
ttest age if ipv_version==2 | ipv_version==3, by(ipv_version)
tab edcat ipv_version, col chi2
tab mstatus ipv_version, col chi2
tab vid ipv_version, col chi2
mlogit ipv_version female age i.mstatus i.vid
test female age 2.mstatus 3.mstatus /*
*/ 2.vid 3.vid 4.vid 5.vid 6.vid 7.vid 8.vid

* correlate norms & beliefs

spearman belief_tot norm_tot

* first examine frequencies across arms

foreach x of numlist 1/5 {
tab belief`x' ipv_version, col
tab norm`x' ipv_version, col
}

* examine means and totals (assuming DNK/refuse=0)

tabstat belief_tot, stat(n mean sd variance) by(ipv_version)
tabstat norm_tot, stat(n mean sd variance) by(ipv_version)

***** primary analysis: beliefs

* establish violation of proportional odds assumption

ologit belief_tot i.ipv_version i.female i.vid, vce(cluster vid) or

tab ipv_version, generate(ipv_version)
tab vid, generate(vid)
quietly ologit belief_tot ipv_version2 ipv_version3 female vid2 vid3 vid4 vid5 vid6 vid7 vid8, vce(cluster vid)
brant

* switch to partial proportional odds

gologit2 belief_tot ipv_version2 ipv_version3 female vid2 vid3 vid4 vid5 vid6 vid7 vid8, /*
*/ robust cluster(vid) pl(female vid2 vid3 vid4 vid5 vid6 vid7 vid8) or

***** primary analysis: norms

* establish violation of proportional odds assumption

ologit norm_tot i.ipv_version i.female i.vid, vce(cluster vid) or

quietly ologit norm_tot ipv_version2 ipv_version3 female vid2 vid3 vid4 vid5 vid6 vid7 vid8, vce(cluster vid)
brant

* switch to partial proportional odds

gologit2 norm_tot ipv_version2 ipv_version3 female vid2 vid3 vid4 vid5 vid6 vid7 vid8, /*
*/ robust cluster(vid) pl(female vid2 vid3 vid4 vid5 vid6 vid7 vid8) or

***** sex stratified estimates: beliefs

generate femaleXver2=female*ipv_version2
generate femaleXver3=female*ipv_version3

* show that interaction terms do not vary across logits

quietly ologit belief_tot ipv_version2 ipv_version3 female vid2 vid3 vid4 vid5 vid6 vid7 vid8 /*
*/ femaleXver2 femaleXver3, vce(cluster vid)
brant 

* beliefs: women

gologit2 belief_tot ipv_version2 ipv_version3 vid2 vid3 vid4 vid5 vid6 vid7 vid8 if female==1, /*
*/ robust cluster(vid) pl(vid2 vid3 vid4 vid5 vid6 vid7 vid8) or

* beliefs: men

gologit2 belief_tot ipv_version2 ipv_version3 vid2 vid3 vid4 vid5 vid6 vid7 vid8 if female==0, /*
*/ robust cluster(vid) pl(vid2 vid3 vid4 vid5 vid6 vid7 vid8) or

* test interaction term

xi: gologit2 belief_tot ipv_version2 ipv_version3 female vid2 vid3 vid4 vid5 vid6 vid7 vid8 /*
*/ femaleXver2 femaleXver3, pl(female vid2 vid3 vid4 vid5 vid6 vid7 vid8 femaleXver2 femaleXver3) /*
*/ robust cluster(vid) or 
test femaleXver2 femaleXver3

***** sex stratified estimates: norms

* show that interaction terms do not vary across logits

quietly ologit norm_tot ipv_version2 ipv_version3 female vid2 vid3 vid4 vid5 vid6 vid7 vid8 /*
*/ femaleXver2 femaleXver3, vce(cluster vid)
brant 

* norms: women

gologit2 norm_tot ipv_version2 ipv_version3 vid2 vid3 vid4 vid5 vid6 vid7 vid8 if female==1, /*
*/ robust cluster(vid) pl(vid2 vid3 vid4 vid5 vid6 vid7 vid8) or

* norms: men

gologit2 norm_tot ipv_version2 ipv_version3 vid2 vid3 vid4 vid5 vid6 vid7 vid8 if female==0, /*
*/ robust cluster(vid) pl(vid2 vid3 vid4 vid5 vid6 vid7 vid8) or /* men */

* test interaction term

xi: gologit2 norm_tot ipv_version2 ipv_version3 female vid2 vid3 vid4 vid5 vid6 vid7 vid8 /*
*/ femaleXver2 femaleXver3, pl(female vid2 vid3 vid4 vid5 vid6 vid7 vid8 femaleXver2 femaleXver3) /*
*/ robust cluster(vid) or 
test femaleXver2 femaleXver3

***** sensitivity analysis: try different omnibus variables

poisson belief_one i.ipv_version i.female i.vid, vce(cluster vid) irr
est store belief_one

poisson norm_one i.ipv_version i.female i.vid, vce(cluster vid) irr
est store norm_one

poisson belief_all i.ipv_version i.female i.vid, vce(cluster vid) irr
est store belief_all

poisson norm_all i.ipv_version i.female i.vid, vce(cluster vid) irr
est store norm_all

***** sensitivity analysis: analyze each item separately 

foreach x of numlist 1/5 {
display "* analysis for belief `x'"
poisson belief`x'_yes i.ipv_version i.female i.vid, vce(cluster vid) irr
est store belief`x'
}

foreach x of numlist 1/5 {
display "* analysis for norm `x'"
poisson norm`x'_yes i.ipv_version i.female i.vid, vce(cluster vid) irr
est store norm`x'
}

****** sensitivity analysis: RA/participant sex concordance

generate femaleXra=female*ra_female

* beliefs: first show that interaction terms do not vary across logits, then use partial proportional odds

quietly ologit belief_tot ipv_version2 ipv_version3 female vid2 vid3 vid4 vid5 vid6 vid7 vid8 /*
*/ ra_female femaleXra, vce(cluster vid)
brant 

xi: gologit2 belief_tot ipv_version2 ipv_version3 female vid2 vid3 vid4 vid5 vid6 vid7 vid8 /*
*/ ra_female femaleXra, /*
*/ robust cluster(vid) or pl(female vid2 vid3 vid4 vid5 vid6 vid7 vid8 ra_female femaleXra)

* norms: first show that interaction terms do not vary across logits, then use partial proportional odds

quietly ologit norm_tot ipv_version2 ipv_version3 female vid2 vid3 vid4 vid5 vid6 vid7 vid8 /*
*/ ra_female femaleXra, vce(cluster vid)
brant

xi: gologit2 norm_tot ipv_version2 ipv_version3 female vid2 vid3 vid4 vid5 vid6 vid7 vid8 /*
*/ ra_female femaleXra, /*
*/ robust cluster(vid) or pl(female vid2 vid3 vid4 vid5 vid6 vid7 vid8 ra_female femaleXra)

***** sensitivity analysis: use PCA to generate dependent variables (response to reviewer #4)

quietly pca belief1_yes belief2_yes belief3_yes belief4_yes belief5_yes, correlation
/* quietly predict belief_index */
summarize belief_index, detail
regress belief_index i.ipv_version i.female i.vid, vce(cluster vid) 

quietly pca norm1_yes norm2_yes norm3_yes norm4_yes norm5_yes, correlation
/* quietly predict norm_index */
summarize norm_index, detail
regress norm_index i.ipv_version i.female i.vid, vce(cluster vid) 

log close

